<template>
  <div>
    <el-table :data="tebleData.results" border stripe v-loading="loading" :height="offsetHeight">
      <el-table-column type="index" label="序号" width="80" align="center">
      </el-table-column>
      <el-table-column prop="role_name" label="角色名称" width="" align="center">
      </el-table-column>
      <el-table-column prop="check_limit" label="审核期限（天）" width="" align="center">
      </el-table-column>
      <el-table-column label="操作" width="" align="center">
        <template slot-scope="{row}">
          <el-button type="primary" size="mini" @click="edit(row)">编辑</el-button>
        </template>
      </el-table-column>
    </el-table>

    <el-dialog title="时间设置" :visible.sync="show" width="30%" @close="cancel">
      <el-form :model="checkList" ref="checkList" label-width="120px" size="normal">
        <el-form-item label="角色名称">
          <el-select v-model="checkList.role_name" value-key="role_name" class="wid" :disabled="true">
            <el-option v-for="item in roleNames" :key="item.value" :label="item.label" :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="审核期限（天）">
          <el-input v-model="checkList.check_limit"></el-input>
        </el-form-item>
      </el-form>

      <span slot="footer">
        <el-button type="danger" @click="cancel">取消</el-button>
        <el-button type="primary" @click="onConfirm" :loading="loading">确认</el-button>
      </span>
    </el-dialog>

  </div>
</template>
<script>
export default {
  name: 'PartDate',
  components: {

  },
  props: {

  },
  data () {
    return {
      offsetHeight: document.documentElement.clientHeight - 220,
      loading: false,
      tebleData: {},
      show: false,
      checkList: {},
      roleNames: [
        // 0：机构上报｜1：填报单位审核｜2：保障部审核｜3：内设机构审核｜51：电子政务部审核｜4：第三方机构审核｜52：电子政务部审核｜6：财政局审核
        // { label: '机构上报', value: '0' },
        { label: '填报单位审核', value: '1' },
        { label: '保障部审核', value: '2' },
        { label: '内设机构审核', value: '3' },
        { label: '第三方机构审核', value: '4' },
        { label: '电子政务部审核', value: '5' },
        { label: '财政局审核', value: '6' }
      ]
    }
  },
  created () {

  },
  mounted () {
    this.init()
  },
  methods: {
    async init () {
      this.loading = true
      const res = await this.$http('sysNodePage', {
        pageNo: '1',
        pageSize: '10',
        del_flag: '0'
      })
      res.results.forEach(item => {
        this.roleNames.forEach(array => {
          if (array.value === item.role_name) {
            item.role_name = array.label
          }
        })
      })
      this.tebleData = res
      this.loading = false
    },
    async edit (item) {
      this.checkList = {
        id: item.id,
        role_name: item.role_name,
        check_limit: item.check_limit
      }
      this.show = true
    },
    async onConfirm () {
      this.loading = true
      const res = await this.$http('sysNodeAdd', {
        id: this.checkList.id,
        check_limit: this.checkList.check_limit
      })
      this.$tips.success(res.errmsg)
      this.show = false
      this.init()
    },
    cancel () {
      this.show = false
    }
  },
  computed: {

  }
}
</script>
<style lang='scss' scoped>
</style>
